<template>
    <div>
        <van-search v-model="searchVal" placeholder="请输入搜索关键词" />
        <van-cell-group v-for="item in searchData">
            <router-link :to="'/detail/'+item.goods_id">
                <van-cell :title="item.goods_name"/>
            </router-link>
            
        </van-cell-group>

    </div>
</template>

<script setup>
import { ref ,watch} from "vue";
import {useRouter}from "vue-router"
const router=new useRouter()
const searchData=ref([])
let searchVal = ref("");
// 防抖

import { searchApi } from '@/api/api'
watch(searchVal,((searchVal)=>{
    searchApi(searchVal).then((res)=>{
        console.log(res);
        searchData.value = res.data.message.goods
    })
    
}))

</script>

<style lang="scss" scoped></style>